package com.sugar.subscribe.course.module.business.dal.mysql.coachcertificate;

import java.util.*;

import com.sugar.subscribe.course.framework.common.pojo.PageResult;
import com.sugar.subscribe.course.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.sugar.subscribe.course.framework.mybatis.core.mapper.BaseMapperX;
import com.sugar.subscribe.course.framework.mybatis.core.query.MPJLambdaWrapperX;
import com.sugar.subscribe.course.module.business.dal.dataobject.coach.CoachDO;
import com.sugar.subscribe.course.module.business.dal.dataobject.coachcertificate.CoachCertificateDO;
import org.apache.ibatis.annotations.Mapper;
import com.sugar.subscribe.course.module.business.controller.admin.coachcertificate.vo.*;

/**
 * 教练证书 Mapper
 *
 * @author Ysugar
 */
@Mapper
public interface CoachCertificateMapper extends BaseMapperX<CoachCertificateDO> {

    default PageResult<CoachCertificateRespVO> selectPage(CoachCertificatePageReqVO reqVO) {
        return selectJoinPage(reqVO, CoachCertificateRespVO.class, new MPJLambdaWrapperX<CoachCertificateDO>()
                .selectAll(CoachCertificateDO.class)
                .selectAs(CoachDO::getName, CoachCertificateRespVO::getCoachName)
                .leftJoin(CoachDO.class, CoachDO::getId, CoachCertificateDO::getCoachId)
                .eqIfPresent(CoachCertificateDO::getCoachId, reqVO.getCoachId())
                .likeIfPresent(CoachCertificateDO::getName, reqVO.getName())
                .eqIfPresent(CoachCertificateDO::getAuditStatus, reqVO.getAuditStatus())
                .betweenIfPresent(CoachCertificateDO::getCreateTime, reqVO.getCreateTime())
                .likeIfPresent(CoachDO::getName, reqVO.getCoachName())
                .orderByDesc(CoachCertificateDO::getId));
    }

}